package com.apobates.jforum2.troll.actionlog.mapper;

import com.apobates.jforum2.troll.actionlog.entity.BoardActionCollection;
import com.apobates.jforum2.troll.actionlog.stub.vo.BoardActionVo;
import com.apobates.jforum2.troll.utils.core.api.OptionalEntityTransformMapper;
import java.util.Optional;
import java.util.function.Function;

/**
 *
 * @author xiaofanku
 */
public class BoardActionVoMapperEntity implements OptionalEntityTransformMapper<BoardActionCollection, BoardActionVo>{

    @Override
    public Optional<BoardActionVo> transform(Optional<BoardActionCollection> entity) {
        return entity.map(ins->{
            return mapper().apply(ins);
        });
    }
    public static Function<BoardActionCollection,BoardActionVo> mapper(){
        return bac -> {
            BoardActionVo bav = new BoardActionVo();
            bav.setId(bac.getId());
            //版块ID
            bav.setBoardId(bac.getBoardId());
            
            //会员的昵称
            bav.setMemberNickname(bac.getMemberNickname());
            //是否允许回复|是否允话评论,true(1)允许,false(0)不允许
            bav.setMemberId(bac.getMemberId());
            //动作ForumActionEnum.symbol
            bav.setAction(bac.getAction().getSymbol());
            bav.setActionTitle(bac.getAction().getTitle());
            //创建日期
            bav.setEntryDateTime(bac.getEntryDateTime());
            //IP
            bav.setIpAddr(bac.getIpAddr());
            bav.setToken(bac.getToken());
            // 角色会员等级需求
            bav.setRodeMember(bac.getRodeMember());
            return bav;
        };
    }
}